package com.cloud.code.牛客网;

import java.util.*;

public class Test68 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){

            String line = scanner.nextLine();
            char[] chars = line.toCharArray();
            Map<Character,Integer> charactes = new LinkedHashMap<>();

            for (int i = 0; i < chars.length; i++) {
                char tem = chars[i];
                charactes.put(tem,charactes.getOrDefault(tem,0)+1);
            }

            List<Map.Entry<Character,Integer>> list = new ArrayList<>(charactes.entrySet());
            list.sort(new Comparator<Map.Entry<Character, Integer>>() {
                @Override
                public int compare(Map.Entry<Character, Integer> o1, Map.Entry<Character, Integer> o2) {
                    if(o2.getValue()!=o1.getValue()){
                        return o2.getValue()-o1.getValue();
                    }else {
                        return o1.getKey()-o2.getKey();
                    }

                }
            });

            for (int i = 0; i < list.size(); i++) {
                System.out.print(list.get(i).getKey());
            }

        }
    }
}
